package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.service.IHomepageService;
import org.example.model.pojo.Homepage;
import cn.jiyun.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【-Homepage】操作接口
 *
 * @author
 * @since 2024-12-19
 */
@RestController
@RequestMapping("/homepage")
@Api(tags = "操作接口")
@Slf4j
public class HomepageController {

    @Autowired
    public IHomepageService homepageService;



    /**
     * 接口：查询所有
     */
    @PostMapping("/findList")
    @ApiOperation("查询所有")
    public List<Homepage> getList() {
        return homepageService.list();
    }

//    @PostMapping("/findPrice")
//    public Result findPrice(@RequestBody Homepage homepage) {
//        return Result.ok(homepageService.findPrice(homepage));
//    }



    @GetMapping("/findPrice")
    public List<Homepage>  findPrice() {
        List<Homepage> homepageList = homepageService.findPrice();
        return homepageList;
    }

    @GetMapping("/findChoose")
    public List<Homepage> findChoose(){
        List<Homepage> homepages=homepageService.findChoose();
        return homepages;
    }


    @GetMapping("/findById/{id}")
    public Result find(@PathVariable Long id) {
        Homepage byId = homepageService.getById(id);
        return Result.ok(byId);
    }

    @PostMapping("/selectOrder")
    public List<Homepage> selectOrder(@RequestParam Integer[] id) {
        //id 查询条件
        return homepageService.selectOrder(id);
    }
    @PostMapping("/findPage")
    public List<Homepage> findPage(@RequestParam Integer id) {
        //id 查询条件
        return homepageService.findPage(id);
    }


}
